.filter-item {
  vertical-align: top;

  &.update-issues-btn {
    float: right;
    margin-right: 0;

    @include gl-container-width-down(md, panel) {
      float: none;
    }
  }
}

@include gl-container-width-up(sm, panel) {
  .filter-item:not(:last-child) {
    margin-right: 6px;
  }

  .bulk-update {
    .filter-item {
      margin-right: 0;
    }
  }

  .sort-filter {
    display: inline-block;
    float: right;
  }

  .dropdown-menu-sort {
    left: auto;
    right: 0;
  }
}

@include gl-container-width-down(md, panel) {
  .filter-item {
    display: block;
    margin: 0 0 10px;
  }

  .dropdown-menu-toggle.dropdown-menu-toggle,
  .update-issues-btn .btn {
    width: 100%;
  }
}

.filtered-search-wrapper {
  .tokens-container {
    display: flex;
    flex: 1;
    padding-left: 12px;
    position: relative;
    margin-bottom: 0;
    width: 1px;
  }

  .input-token {
    max-width: 200px;
    padding: 0;

    &:hover,
    &:focus {
      background-color: inherit;
      color: inherit;
    }
  }

  .input-token:only-child,
  .input-token:last-child {
    flex: 1;
    max-width: inherit;
  }
}

.filtered-search-token,
.filtered-search-term {
  display: flex;
  flex-shrink: 0;
  margin-top: 2px;
  margin-bottom: 2px;

  .selectable {
    display: flex;
  }

  .name,
  .operator,
  .value {
    display: inline-block;
    padding: 2px 7px;
    @apply gl-text-sm;
  }

  .name,
  .operator,
  .value-container {
    color: var(--gl-token-foreground-color);
  }

  .name,
  .operator,
  .value-container,
  .value {
    display: inline-flex;
    align-self: center;
    align-items: center;
    height: 24px;
  }

  .name {
    background-color: var(--gl-filtered-search-token-type-background-color-default);
    border-radius: 2px 0 0 2px;
    margin-right: 1px;
    text-transform: capitalize;
  }

  .operator {
    background-color: var(--gl-filtered-search-token-operator-background-color-default);
    margin-right: 1px;
  }

  .value-container {
    display: flex;
    align-items: center;
    background-color: var(--gl-filtered-search-token-data-background-color-default);
    border-radius: 0 2px 2px 0;
    margin-right: 4px;
    padding-right: 4px;
  }

  .value {
    padding-right: 0;
  }

  .remove-token {
    display: inline-flex;
    align-self: center;
    padding-left: 8px;
    padding-right: 0;

    .close-icon {
      color: var(--gl-icon-color-subtle);
    }

    &:hover .close-icon {
      color: var(--gl-icon-color-default);
    }

    &.inverted {
      .close-icon {
        color: var(--gl-color-neutral-0);
        opacity: 0.85;
      }

      &:hover .close-icon {
        color: var(--gl-color-neutral-0);
      }
    }
  }
}

.filtered-search-token:hover,
.filtered-search-token .selected,
.filtered-search-term .selected {
  .name {
    background-color: var(--gl-filtered-search-token-type-background-color-hover);
  }

  .operator {
    background-color: var(--gl-filtered-search-token-operator-background-color-hover);
  }

  .value-container {
    background-color: var(--gl-filtered-search-token-data-background-color-hover);
  }
}

.filtered-search-term {
  .name {
    background-color: inherit;
    color: var(--gl-token-foreground-color);
    text-transform: none;
  }

  .selectable {
    cursor: text;
  }
}

.scroll-container {
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  width: 100%;
}

.filtered-search-box {
  position: relative;
  flex: 1;
  display: flex;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--gl-control-border-color-default);
  @apply gl-bg-default;
  border-radius: $gl-border-radius-base;

  &.focus,
  &.focus:hover {
    @apply gl-focus;
  }

  gl-emoji {
    display: inline-block;
    font-family: inherit;
    font-size: inherit;
    vertical-align: inherit;

    img {
      height: $default-icon-size;
      width: $default-icon-size;
    }
  }

  .form-control {
    position: relative;
    min-width: 200px;
    padding-right: 25px;
    padding-left: 0;
    height: #{$input-height - 2px};
    background-color: transparent;
    line-height: inherit;

    &,
    &:focus,
    &:hover {
      outline: none;
      border-color: transparent;
      box-shadow: none;
    }
  }
}

.filtered-search-box-input-container {
  flex: 1;
  position: relative;
  min-width: 0;
  height: #{$input-height - 2px};
  background-color: var(--gl-control-background-color-default);
  border-radius: $gl-border-radius-base;
}

.filtered-search-input-dropdown-menu {
  max-height: $dropdown-max-height-lg;
  max-width: 280px;
  overflow: auto;

  @include gl-container-width-down(md, panel) {
    width: auto;
    left: 0;
    right: 0;
    max-width: none;
    min-width: 100%;
  }
}

.filtered-search-history-dropdown-wrapper {
  position: static;
  display: flex;
  flex-direction: column;
}

.filtered-search-history-dropdown-toggle-button.gl-button {
  border-radius: $gl-border-radius-base-inner 0 0 $gl-border-radius-base-inner;
  margin: -1px 0 -1px -1px;
  flex: 1;
  transition: color 0.1s linear;
  width: auto;
}

.filtered-search-history-dropdown {
  width: 40%;

  @include gl-container-width-down(md, panel) {
    left: 0;
    right: 0;
    max-width: none;
  }
}

.filtered-search-history-dropdown-content {
  max-height: none;

  .filtered-search-history-dropdown-item,
  .filtered-search-history-clear-button {
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

.filtered-search-history-dropdown-token {
  display: inline;

  &:not(:last-child) {
    margin-right: 0.3em;
  }

  > .value {
    font-weight: $gl-font-weight-bold;
  }
}

@include gl-container-width-down(md, panel) {
  .issues-details-filters,
  .epics-details-filters {
    padding-top: $gl-padding-8;
    padding-bottom: $gl-padding-8;
    @apply gl-bg-default;
  }

  .filter-dropdown-container {
    > div {
      margin: 0;

      > .btn {
        margin: 0 0 $gl-input-padding;
        width: 100%;
      }
    }
  }
}

.droplab-dropdown .dropdown-menu .filter-dropdown-item {
  .btn {
    text-overflow: ellipsis;

    svg {
      margin-right: $gl-padding-8;
    }

    .dropdown-label-box {
      border-color: var(--gl-background-color-default);
      border-style: solid;
      border-width: 1px;
      width: 17px;
      height: 17px;
      top: 0;
    }
  }
}

.filter-dropdown-loading {
  padding: 8px 16px;
  text-align: center;
}

.vue-filtered-search-bar-container {
  .gl-search-box-by-click {
    // This enforces width of flex items to be
    // calculated in advance so that content
    // does not overflow.

    min-width: 0;
  }

  @include gl-container-width-up(md, panel) {
    .sort-dropdown-container {
      margin-left: 10px;
    }
  }

  @include gl-container-width-down(md, panel) {
    .sort-dropdown-container {
      margin-top: 10px;
    }
  }
}
